Day 3: Managing Files and Directories

VIM Tips

dd = delete line
u = undo
p = paste (#p)
yy = "yank" copy line (#yy)
G = end of file
#G = go to line #
:#d = delete line (#,# = range)
:#y = copy line (#, # = range)
:set nu = set line numbers
:% = entire file
:#,#j - remove newlines
:%s/pattern.match/replacement
:%s/pattern.match/replacement /g = Replace ALL instances
^ = start of line
$ = end of line
i = insert at cursor
I = insert at start of line
a = insert after cursor
A = insert end of line
o = insert below line
O = insert above line
:! <command> = execute command


Finding Files

locate - Searches database
- updatedb to update database before using

find - Crawls the filesystem
- find / -iname filename

which - show location of binary

whereis - shows binary and location of package


Manipulating Files

tr - Translate file contents

wc - Word Count

cut

sort

diff

awk

sed

ln = Create hard or symbolic links


Text Streams

stdin=0
stout=1
stderr=2

>
>>
< = Take as input
<< = Here string (read until terminated)
- cat <<EOF (Keep reading until end of file)
<<< = Input, keep formatting

2>/dev/null = Send to nowhere. Get rid of junk output.

& = Background
&& = AND
|| = OR

$( ) = Do first
` ` = Do first